The Data

This data is a list of every shooting incident that occurred in NYC from 2006 through the end of the previous calendar year. This dataset is intended for public use and allows for the public to explore the nature of the shooting incidents.

This report is a look at the shooting incidents broken down and explored by each borough in NYC. Included is view of total incidents by borough, an examination of incidents over time by borough, and finally a heatmap identifying the physical locations of incidents.

Step 1. Load the data

Besides the csv file that includes the data the geospatial data will be required for the heatmap.

# Load the dataset
data_url <- 'https://data.cityofnewyork.us/api/views/833y-fsy8/rows.csv?accessType=DOWNLOAD'
data <- read.csv(data_url, stringsAsFactors = FALSE)

# Load geospatial data
boroughs <- st_read("https://data.cityofnewyork.us/api/geospatial/tqmj-j8zm?method=export&format=GeoJSON")
## Reading layer `OGRGeoJSON' from data source 
##   `https://data.cityofnewyork.us/api/geospatial/tqmj-j8zm?method=export&format=GeoJSON' 
##   using driver `GeoJSON'
## Simple feature collection with 5 features and 4 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -74.25559 ymin: 40.49613 xmax: -73.70001 ymax: 40.91553
## Geodetic CRS:  WGS 84

Step 2. Data cleaning and transformation

This step involves checking the data and changing the type where necessary.

Here OCCUR_DATE is changed to a Date type.

Additionally rows with missing data are removed. Because the relatively low number of ‘NAs’ in the data that this report is concerned with then removing them is the simplest solution with a low impact.

Finally the centroid calculation is done for he boroughs, this is simply to allow for the naming on the heatmap later.

# Inspect the first few rows
head(data)
##   INCIDENT_KEY OCCUR_DATE OCCUR_TIME     BORO LOC_OF_OCCUR_DESC PRECINCT
## 1    228798151 05/27/2021   21:30:00   QUEENS                        105
## 2    137471050 06/27/2014   17:40:00    BRONX                         40
## 3    147998800 11/21/2015   03:56:00   QUEENS                        108
## 4    146837977 10/09/2015   18:30:00    BRONX                         44
## 5     58921844 02/19/2009   22:58:00    BRONX                         47
## 6    219559682 10/21/2020   21:36:00 BROOKLYN                         81
##   JURISDICTION_CODE LOC_CLASSFCTN_DESC LOCATION_DESC STATISTICAL_MURDER_FLAG
## 1                 0                                                    false
## 2                 0                                                    false
## 3                 0                                                     true
## 4                 0                                                    false
## 5                 0                                                     true
## 6                 0                                                     true
##   PERP_AGE_GROUP PERP_SEX PERP_RACE VIC_AGE_GROUP VIC_SEX       VIC_RACE
## 1                                           18-24       M          BLACK
## 2                                           18-24       M          BLACK
## 3                                           25-44       M          WHITE
## 4                                             <18       M WHITE HISPANIC
## 5          25-44        M     BLACK         45-64       M          BLACK
## 6                                           25-44       M          BLACK
##   X_COORD_CD Y_COORD_CD Latitude Longitude
## 1    1058925   180924.0 40.66296 -73.73084
## 2    1005028   234516.0 40.81035 -73.92494
## 3    1007668   209836.5 40.74261 -73.91549
## 4    1006537   244511.1 40.83778 -73.91946
## 5    1024922   262189.4 40.88624 -73.85291
## 6    1004234   186461.7 40.67846 -73.92795
##                                         Lon_Lat
## 1 POINT (-73.73083868899994 40.662964620000025)
## 2  POINT (-73.92494232599995 40.81035186300006)
## 3  POINT (-73.91549174199997 40.74260663300004)
## 4  POINT (-73.91945661499994 40.83778200300003)
## 5  POINT (-73.85290950899997 40.88623791800006)
## 6 POINT (-73.92795224099996 40.678456718000064)
str(data)
## 'data.frame':    27312 obs. of  21 variables:
##  $ INCIDENT_KEY           : int  228798151 137471050 147998800 146837977 58921844 219559682 85295722 71662474 83002139 86437261 ...
##  $ OCCUR_DATE             : chr  "05/27/2021" "06/27/2014" "11/21/2015" "10/09/2015" ...
##  $ OCCUR_TIME             : chr  "21:30:00" "17:40:00" "03:56:00" "18:30:00" ...
##  $ BORO                   : chr  "QUEENS" "BRONX" "QUEENS" "BRONX" ...
##  $ LOC_OF_OCCUR_DESC      : chr  "" "" "" "" ...
##  $ PRECINCT               : int  105 40 108 44 47 81 114 81 105 101 ...
##  $ JURISDICTION_CODE      : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ LOC_CLASSFCTN_DESC     : chr  "" "" "" "" ...
##  $ LOCATION_DESC          : chr  "" "" "" "" ...
##  $ STATISTICAL_MURDER_FLAG: chr  "false" "false" "true" "false" ...
##  $ PERP_AGE_GROUP         : chr  "" "" "" "" ...
##  $ PERP_SEX               : chr  "" "" "" "" ...
##  $ PERP_RACE              : chr  "" "" "" "" ...
##  $ VIC_AGE_GROUP          : chr  "18-24" "18-24" "25-44" "<18" ...
##  $ VIC_SEX                : chr  "M" "M" "M" "M" ...
##  $ VIC_RACE               : chr  "BLACK" "BLACK" "WHITE" "WHITE HISPANIC" ...
##  $ X_COORD_CD             : num  1058925 1005028 1007668 1006537 1024922 ...
##  $ Y_COORD_CD             : num  180924 234516 209837 244511 262189 ...
##  $ Latitude               : num  40.7 40.8 40.7 40.8 40.9 ...
##  $ Longitude              : num  -73.7 -73.9 -73.9 -73.9 -73.9 ...
##  $ Lon_Lat                : chr  "POINT (-73.73083868899994 40.662964620000025)" "POINT (-73.92494232599995 40.81035186300006)" "POINT (-73.91549174199997 40.74260663300004)" "POINT (-73.91945661499994 40.83778200300003)" ...
# Convert OCCUR_DATE to Date type
data$OCCUR_DATE <- as.Date(data$OCCUR_DATE, format="%m/%d/%Y")

# Extract Year-Month from OCCUR_DATE
data$YearMonth <- format(data$OCCUR_DATE, "%Y-%m")

#Remove NA
data <- data[!is.na(data$Latitude) & !is.na(data$Longitude), ]

#Calculate the Centroid of Each Borough
boroughs_centroids <- st_centroid(boroughs)

Step 3. Visualization and Analysis

The first visual is a bar chart that provides a clear representation of the total number of incidents in each borough. From the chart, we can observe which boroughs have the highest and lowest number of incidents.

Similar to the first visual the next shows the number of incidents in each borough, but in this case it is broken down by time allowing us to see the trends through time.

## `summarise()` has grouped output by 'YearMonth'. You can override using the
## `.groups` argument.

Next is a linear regression model using one-hot encoding. This data represents a time series of incidents recorded over a period of time (2006-2022). Each observation corresponds to a specific month and year.

# One-hot encoding for boroughs on the aggregated data
incidents_by_time_encoded <- model.matrix(~ BORO - 1, data = incidents_by_time)

# Create a numeric representation of time for regression on the aggregated data
incidents_by_time$TimeNumeric <- as.numeric(incidents_by_time$Date)

# Linear regression
lm_result_time <- lm(n ~ TimeNumeric + ., data = cbind(incidents_by_time, incidents_by_time_encoded))
summary(lm_result_time)
## 
## Call:
## lm(formula = n ~ TimeNumeric + ., data = cbind(incidents_by_time, 
##     incidents_by_time_encoded))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -34.129  -6.384  -0.139   5.702  81.166 
## 
## Coefficients: (7 not defined because of singularities)
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)          51.946123  20.132262   2.580 0.010049 *  
## TimeNumeric          -0.001063   0.001243  -0.855 0.392550    
## YearMonth2006-02     -6.367044   7.218344  -0.882 0.378006    
## YearMonth2006-03     -5.337277   7.202156  -0.741 0.458869    
## YearMonth2006-04      5.495679   7.184387   0.765 0.444527    
## YearMonth2006-05      8.927572   7.167347   1.246 0.213278    
## YearMonth2006-06     10.360529   7.149901   1.449 0.147715    
## YearMonth2006-07     20.992422   7.133174   2.943 0.003345 ** 
## YearMonth2006-08     23.425378   7.116054   3.292 0.001039 ** 
## YearMonth2006-09     13.658334   7.099102   1.924 0.054713 .  
## YearMonth2006-10     14.290227   7.082858   2.018 0.043967 *  
## YearMonth2006-11      7.923184   7.066239   1.121 0.262506    
## YearMonth2006-12     10.155077   7.050320   1.440 0.150152    
## YearMonth2007-01     -3.611967   7.034040  -0.513 0.607744    
## YearMonth2007-02     -9.779011   7.017933  -1.393 0.163874    
## YearMonth2007-03     -5.367101   7.458153  -0.720 0.471963    
## YearMonth2007-04     -1.916288   6.987763  -0.274 0.783975    
## YearMonth2007-05     14.515605   6.972668   2.082 0.037678 *  
## YearMonth2007-06     14.948562   6.957245   2.149 0.031962 *  
## YearMonth2007-07     22.580455   6.942491   3.253 0.001192 ** 
## YearMonth2007-08     17.213411   6.927423   2.485 0.013164 *  
## YearMonth2007-09      9.446367   6.912536   1.367 0.172147    
## YearMonth2007-10     14.278260   6.898304   2.070 0.038788 *  
## YearMonth2007-11      1.911217   6.883779   0.278 0.781360    
## YearMonth2007-12     -0.256890   6.869899  -0.037 0.970180    
## YearMonth2008-01     -2.223934   6.855739  -0.324 0.745727    
## YearMonth2008-02     -8.990978   6.841767  -1.314 0.189177    
## YearMonth2008-03      0.639852   6.828868   0.094 0.925372    
## YearMonth2008-04      5.672808   6.815262   0.832 0.405448    
## YearMonth2008-05     13.904702   6.802278   2.044 0.041267 *  
## YearMonth2008-06     14.537658   6.789049   2.141 0.032547 *  
## YearMonth2008-07     21.969551   6.776431   3.242 0.001236 ** 
## YearMonth2008-08     18.202507   6.763584   2.691 0.007266 ** 
## YearMonth2008-09     14.635463   6.750932   2.168 0.030458 *  
## YearMonth2008-10      5.867357   6.738875   0.871 0.384193    
## YearMonth2008-11      1.300313   6.726611   0.193 0.846766    
## YearMonth2008-12      8.132206   6.714932   1.211 0.226227    
## YearMonth2009-01     -3.634838   6.703059  -0.542 0.587786    
## YearMonth2009-02     -2.001882   6.691388  -0.299 0.764885    
## YearMonth2009-03     -3.772115   6.681019  -0.565 0.572502    
## YearMonth2009-04      2.660841   6.669733   0.399 0.690041    
## YearMonth2009-05      9.892735   6.659004   1.486 0.137772    
## YearMonth2009-06     11.925691   6.648119   1.794 0.073214 .  
## YearMonth2009-07     17.757584   6.637782   2.675 0.007620 ** 
## YearMonth2009-08     17.590540   6.627303   2.654 0.008105 ** 
## YearMonth2009-09     11.605639   7.095756   1.636 0.102320    
## YearMonth2009-10      4.255390   6.607290   0.644 0.519730    
## YearMonth2009-11      7.888346   6.597431   1.196 0.232178    
## YearMonth2009-12      0.520239   6.588089   0.079 0.937079    
## YearMonth2010-01     -4.846805   6.578645  -0.737 0.461490    
## YearMonth2010-02      0.386151   6.569413   0.059 0.953142    
## YearMonth2010-03      2.215918   6.561257   0.338 0.735657    
## YearMonth2010-04      9.248874   6.552432   1.412 0.158479    
## YearMonth2010-05      9.080768   6.544095   1.388 0.165635    
## YearMonth2010-06     19.713724   6.535693   3.016 0.002639 ** 
## YearMonth2010-07     18.145617   6.527769   2.780 0.005567 ** 
## YearMonth2010-08     16.578573   6.519794   2.543 0.011183 *  
## YearMonth2010-09     12.411529   6.512037   1.906 0.057015 .  
## YearMonth2010-10      6.275565   6.990851   0.898 0.369624    
## YearMonth2010-11      4.076379   6.497413   0.627 0.530585    
## YearMonth2010-12      1.708272   6.490534   0.263 0.792468    
## YearMonth2011-01     -3.458772   6.483643  -0.533 0.593862    
## YearMonth2011-02     -4.225816   6.476974  -0.652 0.514306    
## YearMonth2011-03     -5.996049   6.471142  -0.927 0.354421    
## YearMonth2011-04      3.436907   6.464896   0.532 0.595132    
## YearMonth2011-05     11.468801   6.459066   1.776 0.076175 .  
## YearMonth2011-06     11.901757   6.453262   1.844 0.065507 .  
## YearMonth2011-07     20.533650   6.447859   3.185 0.001506 ** 
## YearMonth2011-08     19.766606   6.442498   3.068 0.002226 ** 
## YearMonth2011-09     26.399562   6.437363   4.101 4.53e-05 ***
## YearMonth2011-10     14.031456   6.432609   2.181 0.029450 *  
## YearMonth2011-11      3.064412   6.427921   0.477 0.633681    
## YearMonth2011-12      6.696305   6.423600   1.042 0.297515    
## YearMonth2012-01     -0.670739   6.419360  -0.104 0.916809    
## YearMonth2012-02     -3.237783   6.415349  -0.505 0.613913    
## YearMonth2012-03      2.593047   6.411803   0.404 0.686013    
## YearMonth2012-04      2.026004   6.408235   0.316 0.751966    
## YearMonth2012-05     11.257897   6.405001   1.758 0.079184 .  
## YearMonth2012-06     13.290853   6.401885   2.076 0.038203 *  
## YearMonth2012-07     26.122746   6.399090   4.082 4.91e-05 ***
## YearMonth2012-08     14.955702   6.396428   2.338 0.019625 *  
## YearMonth2012-09      4.788658   6.393997   0.749 0.454118    
## YearMonth2012-10     -0.579448   6.391864  -0.091 0.927790    
## YearMonth2012-11     -3.546492   6.389889  -0.555 0.579038    
## YearMonth2012-12     -3.114599   6.388198  -0.488 0.625998    
## YearMonth2013-01      0.718357   6.386678   0.112 0.910473    
## YearMonth2013-02    -12.316544   6.879270  -1.790 0.073768 .  
## YearMonth2013-03     -6.018920   6.384428  -0.943 0.346092    
## YearMonth2013-04     -4.185963   6.383582  -0.656 0.512180    
## YearMonth2013-05     -3.154070   6.382985  -0.494 0.621344    
## YearMonth2013-06      4.878886   6.382598   0.764 0.444851    
## YearMonth2013-07      5.310779   6.382443   0.832 0.405604    
## YearMonth2013-08      9.543735   6.382513   1.495 0.135230    
## YearMonth2013-09      1.176691   6.382815   0.184 0.853783    
## YearMonth2013-10      2.208585   6.383329   0.346 0.729439    
## YearMonth2013-11     -3.158459   6.384088  -0.495 0.620919    
## YearMonth2013-12     -4.526566   6.385045  -0.709 0.478572    
## YearMonth2014-01     -1.293610   6.386261  -0.203 0.839529    
## YearMonth2014-02    -12.260654   6.387710  -1.919 0.055286 .  
## YearMonth2014-03     -0.830887   6.389218  -0.130 0.896563    
## YearMonth2014-04     -2.997930   6.391108  -0.469 0.639141    
## YearMonth2014-05      3.233963   6.393158   0.506 0.613102    
## YearMonth2014-06      8.066919   6.395503   1.261 0.207551    
## YearMonth2014-07      9.698812   6.397993   1.516 0.129934    
## YearMonth2014-08     11.331768   6.400793   1.770 0.077045 .  
## YearMonth2014-09     -0.635276   6.403824  -0.099 0.921002    
## YearMonth2014-10      3.596618   6.406976   0.561 0.574709    
## YearMonth2014-11     -0.970426   6.410459  -0.151 0.879713    
## YearMonth2014-12      5.661467   6.414049   0.883 0.377680    
## YearMonth2015-01      1.094423   6.417983   0.171 0.864641    
## YearMonth2015-02     -8.672621   6.422146  -1.350 0.177260    
## YearMonth2015-03     -3.642854   6.426103  -0.567 0.570951    
## YearMonth2015-04     -1.009897   6.430700  -0.157 0.875250    
## YearMonth2015-05     14.021996   6.435365   2.179 0.029629 *  
## YearMonth2015-06      4.854952   6.440409   0.754 0.451174    
## YearMonth2015-07      4.286845   6.445506   0.665 0.506183    
## YearMonth2015-08     10.319801   6.450995   1.600 0.110053    
## YearMonth2015-09      0.952757   6.456709   0.148 0.882726    
## YearMonth2015-10     -1.415349   6.462452  -0.219 0.826697    
## YearMonth2015-11     -1.182393   6.468608  -0.183 0.855009    
## YearMonth2015-12      1.649500   6.474777   0.255 0.798975    
## YearMonth2016-01     -6.117544   6.481371  -0.944 0.345522    
## YearMonth2016-02     -7.084588   6.488188  -1.092 0.275195    
## YearMonth2016-03     -6.053758   6.494765  -0.932 0.351566    
## YearMonth2016-04     -7.420801   6.502009  -1.141 0.254081    
## YearMonth2016-05     -0.188908   6.509229  -0.029 0.976855    
## YearMonth2016-06      1.444048   6.516905   0.222 0.824693    
## YearMonth2016-07      0.675941   6.524541   0.104 0.917513    
## YearMonth2016-08     15.108897   6.532646   2.313 0.020984 *  
## YearMonth2016-09      3.941854   6.540969   0.603 0.546918    
## YearMonth2016-10     -0.626253   6.549228  -0.096 0.923844    
## YearMonth2016-11     -6.193297   6.557974  -0.944 0.345253    
## YearMonth2016-12     -6.761404   6.566643  -1.030 0.303480    
## YearMonth2017-01     -7.928448   6.575810  -1.206 0.228288    
## YearMonth2017-02    -11.895491   6.585190  -1.806 0.071230 .  
## YearMonth2017-03    -10.265725   6.593844  -1.557 0.119896    
## YearMonth2017-04     -5.232768   6.603626  -0.792 0.428356    
## YearMonth2017-05     -3.800875   6.613292  -0.575 0.565633    
## YearMonth2017-06      1.232081   6.623487   0.186 0.852478    
## YearMonth2017-07     -0.536026   6.633550  -0.081 0.935617    
## YearMonth2017-08     -2.103070   6.644153  -0.317 0.751683    
## YearMonth2017-09     -3.270113   6.654962  -0.491 0.623292    
## YearMonth2017-10     -3.438220   6.665617  -0.516 0.606126    
## YearMonth2017-11     -9.005264   6.676829  -1.349 0.177802    
## YearMonth2017-12     -5.973371   6.687872  -0.893 0.372036    
## YearMonth2018-01     -3.540415   6.699482  -0.528 0.597325    
## YearMonth2018-02    -12.907458   6.711294  -1.923 0.054802 .  
## YearMonth2018-03     -9.877692   6.722134  -1.469 0.142108    
## YearMonth2018-04     -7.444735   6.734325  -1.105 0.269278    
## YearMonth2018-05     -1.412842   6.746311  -0.209 0.834170    
## YearMonth2018-06     -2.979886   6.758891  -0.441 0.659416    
## YearMonth2018-07      1.852007   6.771251   0.274 0.784531    
## YearMonth2018-08     -2.515037   6.784214  -0.371 0.710945    
## YearMonth2018-09     -4.482080   6.797372  -0.659 0.509838    
## YearMonth2018-10     -4.250187   6.810288  -0.624 0.532750    
## YearMonth2018-11     -8.835088   7.286495  -1.213 0.225666    
## YearMonth2018-12     -5.785338   6.837103  -0.846 0.397711    
## YearMonth2019-01     -8.152382   6.851011  -1.190 0.234416    
## YearMonth2019-02    -11.737283   7.325104  -1.602 0.109474    
## YearMonth2019-03     -7.689659   6.878000  -1.118 0.263898    
## YearMonth2019-04     -7.256702   6.892451  -1.053 0.292727    
## YearMonth2019-05     -4.424809   6.906612  -0.641 0.521924    
## YearMonth2019-06      0.808147   6.921425   0.117 0.907079    
## YearMonth2019-07      3.440040   6.935934   0.496 0.620049    
## YearMonth2019-08      0.472996   6.951105   0.068 0.945766    
## YearMonth2019-09     -3.294047   6.966456  -0.473 0.636453    
## YearMonth2019-10     -4.462154   6.981481  -0.639 0.522913    
## YearMonth2019-11     -6.229198   6.997183  -0.890 0.373601    
## YearMonth2019-12     -7.797305   7.012546  -1.112 0.266510    
## YearMonth2020-01     -1.564349   7.028594  -0.223 0.823927    
## YearMonth2020-02    -10.131392   7.044816  -1.438 0.150785    
## YearMonth2020-03     -6.100562   7.060148  -0.864 0.387799    
## YearMonth2020-04     -6.467606   7.076703  -0.914 0.361028    
## YearMonth2020-05      7.164287   7.092887   1.010 0.312767    
## YearMonth2020-06     32.797243   7.109777   4.613 4.62e-06 ***
## YearMonth2020-07     44.829136   7.126282   6.291 5.19e-10 ***
## YearMonth2020-08     42.062092   7.143502   5.888 5.73e-09 ***
## YearMonth2020-09     17.695049   7.160887   2.471 0.013677 *  
## YearMonth2020-10     12.926942   7.177869   1.801 0.072086 .  
## YearMonth2020-11      7.759898   7.195578   1.078 0.281167    
## YearMonth2020-12      6.391791   7.212869   0.886 0.375794    
## YearMonth2021-01     -0.975253   7.230896  -0.135 0.892746    
## YearMonth2021-02     -2.142296   7.249083  -0.296 0.767668    
## YearMonth2021-03      6.087471   7.265646   0.838 0.402368    
## YearMonth2021-04     16.320427   7.284133   2.241 0.025328 *  
## YearMonth2021-05     25.552320   7.302173   3.499 0.000492 ***
## YearMonth2021-06     19.985276   7.320968   2.730 0.006475 ** 
## YearMonth2021-07     21.017169   7.339302   2.864 0.004297 ** 
## YearMonth2021-08     25.850125   7.358399   3.513 0.000468 ***
## YearMonth2021-09     18.683082   7.377647   2.532 0.011518 *  
## YearMonth2021-10     12.114975   7.396417   1.638 0.101823    
## YearMonth2021-11     10.547931   7.415960   1.422 0.155319    
## YearMonth2021-12     11.579824   7.435014   1.557 0.119752    
## YearMonth2022-01      3.612780   7.454848   0.485 0.628077    
## YearMonth2022-02      0.177879   7.898649   0.023 0.982039    
## YearMonth2022-03     11.675504   7.492998   1.558 0.119582    
## YearMonth2022-04     11.508460   7.513252   1.532 0.125976    
## YearMonth2022-05     14.540353   7.532989   1.930 0.053931 .  
## YearMonth2022-06     14.973309   7.553523   1.982 0.047786 *  
## YearMonth2022-07     26.405202   7.573527   3.487 0.000516 ***
## YearMonth2022-08     11.238158   7.594336   1.480 0.139316    
## YearMonth2022-09     10.871115   7.615283   1.428 0.153813    
## YearMonth2022-10      1.103008   7.635684   0.144 0.885178    
## YearMonth2022-11      0.735964   7.656899   0.096 0.923451    
## YearMonth2022-12            NA         NA      NA       NA    
## BOROBROOKLYN         14.666667   1.132905  12.946  < 2e-16 ***
## BOROMANHATTAN       -21.416667   1.132905 -18.904  < 2e-16 ***
## BOROQUEENS          -18.848039   1.132905 -16.637  < 2e-16 ***
## BOROSTATEN ISLAND   -35.238796   1.147265 -30.715  < 2e-16 ***
## Date                        NA         NA      NA       NA    
## BOROBRONX                   NA         NA      NA       NA    
## BOROBROOKLYN                NA         NA      NA       NA    
## BOROMANHATTAN               NA         NA      NA       NA    
## BOROQUEENS                  NA         NA      NA       NA    
## `BOROSTATEN ISLAND`         NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11.44 on 804 degrees of freedom
## Multiple R-squared:  0.7987, Adjusted R-squared:  0.7468 
## F-statistic: 15.41 on 207 and 804 DF,  p-value: < 2.2e-16

These results show the number of incidents varies significantly in certain months compared to the reference month. There’s a general trend suggesting incidents decrease as time progresses, but this trend isn’t strong enough to be deemed statistically significant.

This final visualization is a heatmap displaying the location of all incidents. This provides an interesting insight with location context for the data.

Heatmap of Shooting Incidents in NYC

Heatmap of Shooting Incidents in NYC

Issues with the report

First, the information provided is only a count of incidents. This means that while one borough may appear to be more likely to have an incident without some more context it is hard to say for sure. One better way to examine the data would be with incidents per capita.

Next, it appears that the number of incidents occuring in NYC has been steadily going down since 2006 only to jump back to much higher counts in 2020 and only going back down slowly. There is no way to know what might have caused this given the data available. Perhaps it has to do with global events or local policies. Only conjectures can be made without further information. This would be an easy place to let personal bias creep into the report.

Finally, because of the way the heatmap works the best way to view this is as an html file. The pdf file only provides a screenshot of the heatmap data.

sessionInfo()
## R version 4.2.2 (2022-10-31 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 22621)
## 
## Matrix products: default
## 
## locale:
## [1] LC_COLLATE=English_United States.utf8 
## [2] LC_CTYPE=English_United States.utf8   
## [3] LC_MONETARY=English_United States.utf8
## [4] LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.utf8    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] webshot_0.5.5        sf_1.0-14            leaflet.extras_1.0.0
##  [4] leaflet_2.1.2        lubridate_1.9.2      forcats_1.0.0       
##  [7] stringr_1.5.0        dplyr_1.1.2          purrr_1.0.1         
## [10] readr_2.1.4          tidyr_1.3.0          tibble_3.2.1        
## [13] ggplot2_3.4.2        tidyverse_2.0.0     
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.11        png_0.1-8          ps_1.7.5           class_7.3-20      
##  [5] digest_0.6.33      utf8_1.2.3         mime_0.12          R6_2.5.1          
##  [9] evaluate_0.21      e1071_1.7-13       highr_0.10         pillar_1.9.0      
## [13] rlang_1.1.1        rstudioapi_0.15.0  callr_3.7.3        jquerylib_0.1.4   
## [17] rmarkdown_2.23     labeling_0.4.2     htmlwidgets_1.6.2  munsell_0.5.0     
## [21] proxy_0.4-27       compiler_4.2.2     xfun_0.39          pkgconfig_2.0.3   
## [25] htmltools_0.5.5    tidyselect_1.2.0   fansi_1.0.4        tzdb_0.4.0        
## [29] withr_2.5.0        wk_0.7.3           grid_4.2.2         jsonlite_1.8.7    
## [33] gtable_0.3.3       lifecycle_1.0.3    DBI_1.1.3          magrittr_2.0.3    
## [37] units_0.8-3        scales_1.2.1       KernSmooth_2.23-20 cli_3.6.0         
## [41] stringi_1.7.12     cachem_1.0.8       farver_2.1.1       bslib_0.5.0       
## [45] ellipsis_0.3.2     generics_0.1.3     vctrs_0.6.3        s2_1.1.4          
## [49] tools_4.2.2        glue_1.6.2         markdown_1.7       hms_1.1.3         
## [53] crosstalk_1.2.0    processx_3.8.2     fastmap_1.1.1      yaml_2.3.7        
## [57] timechange_0.2.0   colorspace_2.1-0   classInt_0.4-9     knitr_1.43        
## [61] sass_0.4.7